<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script src="../vue.global.js"></script>
  <title>Document</title>
</head>
<body>
  <div id="root">
    {{data.title}}
    {{count.x}}
  </div>
  <script type="module">
    const { createApp, reactive, ref, onMounted } = window.Vue
    
    const app = createApp({
      setup() {
        const data = reactive({
          title: 'hello'
        })

        const count = ref({
          x: 100
        })

        // 定义单独的钩子函数的目的是：有利于hooks的封装
        onMounted(() => {
          data.title = 'world'
          console.log(count.value.x)
        })

        return {
          data, 
          count
        }
      }
    })

    let vm = app.mount('#root')
  </script>
</body>
</html>